package com.xbfinal.eduservice.controller;


import cn.hutool.extra.ssh.JschUtil;
import cn.hutool.json.JSON;
import com.xbfinal.commonUtils.Result;
import com.xbfinal.eduservice.entity.EduVideo;
import com.xbfinal.eduservice.service.EduVideoService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 课程视频 前端控制器
 * </p>
 *
 * @author xbfinal
 * @since 2023-01-09
 */
@Slf4j
@RestController
@RequestMapping("/eduservice/video")
public class EduVideoController {

    @Autowired
    private EduVideoService eduVideoService;

    /**
     * 添加小节
     * @param eduVideo
     * @return
     */
    @ApiOperation("添加小节")
    @PostMapping("addVideo")
    public Result addVideo(@RequestBody EduVideo eduVideo){
        log.info("添加小节");
        eduVideoService.save(eduVideo);
        return Result.ok();
    }

    /**
     * 删除小节
     * TODO 后面需要完善：删除小节和视频
     * TODO 微服务 调用vod 微服务 实现删除
     * @param id
     * @return
     */
    @ApiOperation("删除小节")
    @DeleteMapping("{id}")
    public Result Delete(@PathVariable("id") String id){
        log.info("删除小节");
        eduVideoService.removeById(id);
        return Result.ok();
    }
}

